<style>
    .order-header-first {
        font-size: small;color: grey;
    }
    .order-header {
        font-size: small;color: grey;padding-left: 5%
    }
    .order-header-text {
        padding-left: 5px
    }
</style>

@foreach($paginator as $row)
    <div id="order_{{ $row->order_no }}" class="box box-primary">
        <div class="box-header with-border" style="background-color: #f1f9fd">
            <span class="order-header-first">订单号: </span><span class="order-header-text">{{ $row->order_no }}</span>
            <span class="order-header">收货国家: </span><span class="order-header-text">{{ $row->receiver->country }}</span>
            <span class="order-header">订单平台: </span><span class="order-header-text">{{ \App\Models\Basics\SysPlat::getSysPlatTitle($row->plat_id) }}</span>
            <span class="order-header">下单时间: </span><span class="order-header-text">{{ $row->order_at }}</span>
        </div>

        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th width="8%">发货单号</th>
                        <th width="8%">发货方式</th>
                        <th width="8%">SKU</th>
                        <th width="20%">SKU名称</th>
                        <th width="8%">申请发货状态</th>
                        <th width="8%">下单数量</th>
                        <th width="8%">申请发货数量</th>
                        <th width="8%">实际发货数量</th>
                        <th width="8%">发货状态</th>
                        <th width="8%">发货账号</th>
                        <th width="8%">发货时间</th>
                        {{--<th width="5%">海外仓仓库</th>
                        <th width="5%">站点</th>
                        <th width="5%">申请备注</th>
                        <th width="5%">发货备注</th>
                        <th width="5%">平台</th>
                        <th width="5%">申请发货销售人员</th>
                        <th width="5%">订单日期</th>
                        <th width="5%">平台SKU</th>
                        <th width="5%">物流单号</th>
                        <th width="5%">运输SLA</th>
                        <th width="5%">运输方式</th>--}}
                    </tr>
                </thead>

                <tbody>
                @if($row->detail->isNotEmpty())

                    @foreach($row->detail as $val)

                        <tr>
                            <td>{{ $row->delivery_no ?? '' }}</td>
                            <td>{{ \App\Models\CustomerDelivery\CustomerDelivery::$_deliveryType[$row->delivery_type] ?? '无' }}</td>
                            <td>{{ $val->sku->psku_code ?? '' }}</td>
                            <td>{{ $val->sku->psku_cn ?? '' }}</td>
                            <td>{{ \App\Models\CustomerDelivery\CustomerOrderDetails::$_status[$val->order_detail->status] ?? '' }}</td>
                            <td>{{ $val->order_detail->order_num ?? 0 }}</td>
                            <td>{{ $val->apply_num ?? '' }}</td>
                            <td>{{ $val->ship_num ?? '' }}</td>
                            <td>{{ \App\Models\CustomerDelivery\CustomerDeliveryDetail::$_status[$val->status] ?? '' }}</td>
                            <td>{{ \App\Models\Basics\SysPlatAccount::getAccountById($val->account_id) ?? '无' }}</td>
                            <td>{{ $row->delivered_at ?? '' }}</td>
                            {{-- <td>{{ $val->warehouse_id ?? '' }}</td>
                             <td>{{ \App\Models\Basics\SysArea::getSysAreaById($row->area_id) ?? '无' }}</td>
                             <td>{{ $val->apply_remarks ?? '' }}</td>
                             <td>{{ $val->delivery_remarks ?? '' }}</td>
                             <td>{{ \App\Models\CustomerDelivery\CustomerOrder::$_shipOrderOrigin[$row->order_origin] ?? '无' }}</td>
                             <td>{{ \App\Util\User::getUsernameById(isset($row->seller_id)) ?? '无' }}</td>
                             <td>{{ $row->order_at ?? '' }}</td>
                             <td>{{ $val->seller_sku ?? '' }}</td>
                             <td>{{ $val->tracking_no ?? '' }}</td>
                             <td>{{ $val->logistics_sla ?? '' }}</td>
                             <td>{{ $val->logistics_type ?? '' }}</td>--}}
                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
        </div>

        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th width="10%">海外仓仓库</th>
                    <th width="10%">站点</th>
                    <th width="10%">申请备注</th>
                    <th width="10%">发货备注</th>
                    <th width="10%">平台</th>
                    <th width="8%">销售申请人员</th>
                    <th width="10%">订单日期</th>
                    <th width="8%">平台SKU</th>
                    <th width="8%">物流状态</th>
                    <th width="8%">物流单号</th>
                    <th width="8%">运输SLA</th>
                    <th width="8%">运输方式</th>
                </tr>
                </thead>

                <tbody>
                @if($row->detail->isNotEmpty())
                    @foreach($row->detail as $val)
                        <tr>
                            <td>{{  \App\Models\OverSeasBa\Warehouse::getCodeById($val->warehouse_id) ?? '' }}</td>
                            <td>{{ \App\Models\Basics\SysArea::getSysAreaById($row->area_id) ?? '无' }}</td>
                            <td>{{ $val->apply_remarks ?? '' }}</td>
                            <td>{{ $val->delivery_remarks ?? '' }}</td>
                            <td>{{ \App\Models\Basics\SysPlat::getSysPlatTitle($row->order->order_origin) ?? '' }}</td>
                            <td>{{ \App\Util\User::getUsernameById(isset($row->seller_id)) ?? '无' }}</td>
                            <td>{{ $row->order_at ?? '' }}</td>
                            <td>{{ $val->seller_sku ?? '' }}</td>
                            <td>{{ $val->logistics_status ?? '' }}</td>
                            <td>{{ $val->tracking_no ?? '' }}</td>
                            <td>{{ $val->logistics_sla ?? '' }}</td>
                            <td>{{ $val->logistics_type ?? '' }}</td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
        </div>

        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>收货国家</th>
                    <th>收货人</th>
                    <th>收货地址</th>
                    <th>州</th>
                    <th>城市</th>
                    <th>邮编</th>
                    <th>电话</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{{ $row->receiver->country ?? '' }}</td>
                    <td>{{ $row->receiver->receiver ?? '' }}</td>
                    <td>{{ $row->receiver->address ?? '' }}</td>
                    <td>{{ $row->receiver->state ?? '' }}</td>
                    <td>{{ $row->receiver->city ?? '' }}</td>
                    <td>{{ $row->receiver->postcode ?? '' }}</td>
                    <td>{{ $row->receiver->phone ?? '' }}</td>
                </tr>
                </tbody>
            </table>
        </div>

    </div>
@endforeach


<script language="JavaScript" type="text/javascript">
    $(function () {

        //列展开 (默认添加模板数据)
        $('.grid-expand-grid-row').each(function() {
            let name = $(this).data('name');
            let row = $(this).closest('tr');
            row.after($('template.grid-expand-'+name).html());
        });

        //列展开
        $('.grid-expand-grid-row').on('click', function () {
            if ($(this).data('inserted') == '0') {
                $(this).data('inserted', 1);
            }
            $("i", this).toggleClass("fa-angle-double-down fa-angle-double-up");
        });

    });
</script>
